from django.urls import path

# from rest_framework_jwt.views import obtain_jwt_token

from apps.meiduo_admin.login import admin_obtain_jwt_token
from apps.meiduo_admin.views.brand import BrandModelViewSet
from apps.meiduo_admin.views.home import *
from apps.meiduo_admin.views.image import SKUImageListView, SKUListAPIView
from apps.meiduo_admin.views.order import OrderModelViewSet
from apps.meiduo_admin.views.permission import PermissionModelViewSet, ContentTypeModelView, GroupView, \
    GroupSimpleAPIView
from apps.meiduo_admin.views.sku import SKUModelViewSet, GoodsCategoryListAPIView, SPUListView, SPUSpecifcationAPIView
from apps.meiduo_admin.views.spu import SPUModelSerializerView
from apps.meiduo_admin.views.user import UserModelViewSet

urlpatterns = [

    path('authorizations/', admin_obtain_jwt_token),
    path('statistical/day_active/', UserDailyActiveCountView.as_view()),
    path('statistical/total_count/', UserSumCountView.as_view()),
    path('statistical/day_orders/', UserDailyOrderCountView.as_view()),
    path('statistical/day_increment/', UserDayNewCreateCount.as_view()),
    path('statistical/month_increment/', UserMonthCountView.as_view()),

    # path('users/', UserListView.as_view()),
    # path('skus/images/', SKUImageListView.as_view()),
    path('skus/simple/', SKUListAPIView.as_view()),
    path('skus/categories/', GoodsCategoryListAPIView.as_view()),
    path('goods/simple/', SPUListView.as_view()),
    path('goods/<spu_id>/specs/', SPUSpecifcationAPIView.as_view()),

    path('permission/content_types/', ContentTypeModelView.as_view()),
    path('permission/simple/', GroupSimpleAPIView.as_view()),
]

from rest_framework.routers import DefaultRouter

# 可以处理视图的路由器
router = DefaultRouter()
# 向路由器中注册视图集
router.register(r'users', UserModelViewSet, basename='users')  # 用户
router.register(r'skus/images', SKUImageListView, basename='image')  # SKU图片
router.register(r'skus', SKUModelViewSet, basename='skus')  # SKU
router.register(r'goods/brands', BrandModelViewSet, basename='brand')  # SPU
router.register(r'goods', SPUModelSerializerView, basename='spus')  # SPU
router.register(r'orders', OrderModelViewSet, basename='order')  # order
#  权限管理
router.register(r'permission/perms', PermissionModelViewSet, basename='permission')  # order
#组管理
router.register('permission/groups', GroupView, basename='perms')

# 追加路由s
urlpatterns += router.urls
